﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DynamicChart.Data;

namespace Sinochem.TMS.LogisticChartService
{
    public class StructureQuery : IChartDataQuery
    {
        public ChartData GetData(DateRange dateRange, QueryParameter parameter)
        {
            ChartData chart = new ChartData
            {
                Type = ChartType.Pie
            };

            if (dateRange.Mode == "y")
            {
                chart.Caption = string.Format("库存商品结构分析（{0}年）",
                    dateRange.CurrentDate.Year);
            }
            else
            {
                chart.Caption = string.Format("库存商品结构分析（{0}年{1}月）",
                    dateRange.CurrentDate.Year,
                    dateRange.CurrentDate.Month);
            }

            ChartSeriesData seriesData = new ChartSeriesData();
            chart.SeriesData.Add(seriesData);
            seriesData.Caption = "库存";

            seriesData.Items.Add(new ChartDataItem
            {
                Color = "#66C2FF",
                Name = "在库库存",
                Value = new Random().Next(4022, 15020),
                NavigationUrl = string.Empty
            });
            seriesData.Items.Add(new ChartDataItem
            {
                Name = "采购在途库存",
                Color = "#77BB77",
                Value = new Random().Next(1222, 5100),
                NavigationUrl = string.Empty
            });
            seriesData.Items.Add(new ChartDataItem
            {
                Name = "销售在途库存",
                Color = "#EEDC82",
                Value = new Random().Next(1322, 2110),
                NavigationUrl = string.Empty
            });
            seriesData.Items.Add(new ChartDataItem
            {
                Name = "合同库存",
                Color = "#EE6363",
                Value = new Random().Next(222, 1111),
                NavigationUrl = string.Empty
            });

            return chart;
        }
    }
}
